var { getLoginedUser, setTitle,fnLoading, fnHideLoading, fnSuccess, fnFail } = require('../../utils/index')
import { domainStatic } from '../../utils/env.js';
import _ from '../../utils/underscore.js';
import { get, checkCoupon, fnChoose, lsGetStr, fnUpload, post } from '../../utils/request.js';
var WxParse = require('../wxParse/wxParse.js');

// pages/soft/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    redirectTo:'',
    verifyPhone:'',
   other:"",
   image:"",
    desc1:"",
    id:"",
    phone:"",
    disabled: false,
    currentTime: 61,
    text:"获取验证码",
    code:""
  },


  

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that=this;
    fnLoading('加载中...')
    that.setData({
      id:options.id,
    })
    if (this.data.id == 14194){
      setTitle("双软企业申请")
      get({
        path:"/offer/get?id=85"
      })
      .then(function(res){
        res.offer.detail = res.offer.detail.indexOf('%3D') > -1 ? unescape(res.offer.detail) : res.offer.detail;
        console.log(res.offer.detail);
        WxParse.wxParse('detailHtml', 'html', res.offer.detail, that, 5);
        that.setData({
          other:res.offer.name,
          image: res.offer.thumbnail,
          desc1: res.offer.desc1,
        })
        fnHideLoading();
      })
    }else{
      setTitle("高新技术企业")
      get({
        path: "/offer/get?id=87"
      }).then(function (res) {
        res.offer.detail = res.offer.detail.indexOf('%3D') > -1 ? unescape(res.offer.detail) : res.offer.detail;
        WxParse.wxParse('detailHtml', 'html', res.offer.detail, that, 5);
        that.setData({
          other: res.offer.name,
          image: res.offer.thumbnail,
          desc1: res.offer.desc1,
          id:res.offer.id,
        })
        fnHideLoading();
      })
    }
  },
  onShow() {
    checkCoupon();
  },
  but() {
    let that = this;
    let url = '../certificate/index?type=' + this.data.id
    get({
      path: "user/getInfo"
    }).then(function (res) {
      if (!res.user.phone) {
        that.setData({
          verifyPhone: true,
          //redirectTo: url
        })
      } else {
        wx.navigateTo({
          url: url,
        })
      }
    })
    // getLoginedUser()
    //   .then(user => {
    //     console.log(user);
    //     if (!user.phone) {
    //       that.setData({
    //         verifyPhone: true,
    //         redirectTo: url
    //       })
    //     } else {
    //       wx.navigateTo({
    //         url: url
    //       })
    //     }
    //   })
  }
  
})